﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace MyWeb.Data
{
	public class tb_FeedbackDAL : SqlDataProvider
	{

		#region[tb_Feedback_GetbyAll]
		public DataTable tb_Feedback_GetByAll()
		{
			using (var cmd = new SqlCommand("sp_tb_Feedback_GetByAll", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_Feedback_GetbyId]
		public DataTable tb_Feedback_GetById(tb_FeedbackInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_Feedback_GetById", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data.Id));
				var da = new SqlDataAdapter(cmd);
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_Feedback_GetbyTop]
		public DataTable tb_Feedback_GetByTop(string Top, string Where, string Order)
		{
			using (var cmd = new SqlCommand("sp_tb_Feedback_GetByTop", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				var da = new SqlDataAdapter(cmd);
				cmd.Parameters.Add(new SqlParameter("@Top",Top));
				cmd.Parameters.Add(new SqlParameter("@Where",Where));
				cmd.Parameters.Add(new SqlParameter("@Order",Order));
				var dt = new DataTable();
				da.Fill(dt);
				return dt;
			}
		}
		#endregion
		#region[tb_Feedback_Insert]
		public void tb_Feedback_Insert(tb_FeedbackInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_Feedback_Insert", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Email", Data.Email));
				cmd.Parameters.Add(new SqlParameter("@Title", Data.Title));
				cmd.Parameters.Add(new SqlParameter("@Content", Data.Content));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.Parameters.Add(new SqlParameter("@reply", Data.reply));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_Feedback_Update]
		public void tb_Feedback_Update(tb_FeedbackInfo Data)
		{
			using (var cmd = new SqlCommand("sp_tb_Feedback_Update", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data.Id));
				cmd.Parameters.Add(new SqlParameter("@Email", Data.Email));
				cmd.Parameters.Add(new SqlParameter("@Title", Data.Title));
				cmd.Parameters.Add(new SqlParameter("@Content", Data.Content));
				cmd.Parameters.Add(new SqlParameter("@Status", Data.Status));
				cmd.Parameters.Add(new SqlParameter("@reply", Data.reply));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
		#region[tb_Feedback_Delete]
		public void tb_Feedback_Delete(string Data)
		{
			using (var cmd = new SqlCommand("sp_tb_Feedback_Delete", GetConnection()))
			{
				cmd.CommandType = CommandType.StoredProcedure;
				cmd.Parameters.Add(new SqlParameter("@Id", Data));
				cmd.ExecuteNonQuery();
			}
		}
		#endregion
	}
}